package indi.zhifa.study2025.oa.admin.controller;

import indi.zhifa.engine.core.common.web.ann.ZhiFaRestController;
import indi.zhifa.study2025.oa.admin.facade.dep.IDepFacade;
import indi.zhifa.study2025.oa.common.util.ConstantUtil;
import indi.zhifa.study2025.oa.model.expose.dep.dto.DepCreateDto;
import indi.zhifa.study2025.oa.model.expose.dep.dto.DepEditDto;
import indi.zhifa.study2025.oa.model.expose.dep.vo.DepTreeNode;
import indi.zhifa.study2025.oa.model.expose.dep.vo.DepVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Validated
@RequiredArgsConstructor
@Tag(name = "部门接口")
@ZhiFaRestController
@RequestMapping(ConstantUtil.API_PREFIX + "/depMgr")
public class DepController {

    final IDepFacade mDepFacade;

    @Operation(summary = "添加部门")
    @PostMapping("/{parentId}/add")
    public DepVo addDep(@PathVariable("parentId") Long pParentId, @RequestBody DepCreateDto pDepCreateDto){
        return mDepFacade.addDep(pParentId, pDepCreateDto);
    }

    @Operation(summary = "编辑部门")
    @PostMapping("/{id}")
    public DepVo editDep(@PathVariable("id") Long pId, @RequestBody DepEditDto pDepEditDto){
        return mDepFacade.editDep(pId, pDepEditDto);
    }

    @Operation(summary = "删除部门")
    @DeleteMapping("/{id}")
    public DepVo delete(@PathVariable("id") Long pId){
        return mDepFacade.delete(pId);
    }

    @Operation(summary = "查看部门树")
    @GetMapping("/{id}/treeNode")
    public DepTreeNode getTreeNode(@PathVariable("id") Long pId){
        return mDepFacade.getTreeNode(pId);
    }

    @Operation(summary = "产看部门信息")
    @GetMapping("/{id}")
    public DepVo info(@PathVariable("id")  Long pId){
        return mDepFacade.info(pId);
    }

}
